﻿<?xml version="1.0" encoding="utf-8" ?>
<!--
	XML Schema for NQUpdate package description files
	Specification revision: 1.1
	
	Copyright (c) 2010 Andreas Weizel, AWZhome Project
	http://www.awzhome.de/
	
	This file is subject to Mozilla Public License 1.1.
-->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.awzhome.de/xmlns/nqupdate/1.1" xmlns:nqupd="http://www.awzhome.de/xmlns/nqupdate/1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<!-- Root element -->
	<xs:element name="NQUpdate" type="nqupd:RootType" />

	<!-- Simple Types, enumerations -->
	<xs:simpleType name="ConditionTypeEnum">
		<xs:restriction base="xs:string">
			<xs:enumeration value="file" />
			<xs:enumeration value="release" />
			<xs:enumeration value="os" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="PackageTypeEnum">
		<xs:restriction base="xs:string">
			<xs:enumeration value="zip" />
			<xs:enumeration value="nqpackage" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="VersionIDType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,4}\.[0-9]{1,4}" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="VersionConstraintType">
		<xs:restriction base="xs:string">
			<xs:pattern value="(\+\+|\-\-|\+=|\-=|==)[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,4}\.[0-9]{1,4}" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="FormatVersionType">
		<xs:restriction base="xs:string">
			<xs:pattern value="1\.1" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="InstallerExecutionType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="zip" />
			<xs:enumeration value="selfinstall" />
		</xs:restriction>
	</xs:simpleType>

	<!-- Complex types -->
	<xs:complexType name="LocaleTextType">
		<xs:sequence>
			<xs:element name="locale" minOccurs="1" maxOccurs="unbounded">
				<xs:complexType mixed="1">
					<xs:attribute name="lang" type="xs:string" use="required" />
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ConditionType">
		<xs:attribute name="type" type="nqupd:ConditionTypeEnum" use="required" />
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="ver" type="nqupd:VersionConstraintType" use="required" />
	</xs:complexType>

	<xs:complexType name="CompatibilityType">
		<xs:attribute name="ver" type="nqupd:VersionConstraintType" use="required" />
	</xs:complexType>

	<xs:complexType name="ConditionCollectionType">
		<xs:sequence>
			<xs:element name="condition" type="nqupd:ConditionType" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="CompatibilityCollectionType">
		<xs:sequence>
			<xs:element name="condition" type="nqupd:CompatibilityType" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="InstallerFileType">
		<xs:sequence>
			<xs:element name="command-line" type="xs:string" minOccurs="0" maxOccurs="1" />
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="source" type="xs:string" use="required" />
		<xs:attribute name="size" type="xs:long" use="required" />
		<xs:attribute name="checksum" type="xs:string" use="required" />
		<xs:attribute name="type" type="nqupd:InstallerExecutionType" use="required" />
	</xs:complexType>

	<xs:complexType name="DistributionType">
		<xs:sequence>
			<xs:element name="displayname" type="nqupd:LocaleTextType" />
			<xs:element name="displayversion" type="nqupd:LocaleTextType" />
			<xs:element name="releaserefs" type="nqupd:ReleaseRefCollectionType" />
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="ver" type="nqupd:VersionIDType" />
	</xs:complexType>

	<xs:complexType name="RootType">
		<xs:sequence>
			<xs:element name="productgroup" type="nqupd:ProductGroupType" minOccurs="1" maxOccurs="unbounded" />
			<xs:element name="distributions" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="distribution" type="nqupd:DistributionType" minOccurs="1" maxOccurs="unbounded" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="version" type="nqupd:FormatVersionType" use="required" />
	</xs:complexType>

	<xs:complexType name="ProductGroupType">
		<xs:sequence>
			<xs:element name="title" type="nqupd:LocaleTextType" />
			<xs:element name="product" type="nqupd:ProductType" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ProductType">
		<xs:sequence>
			<xs:element name="displayname" type="nqupd:LocaleTextType" />
			<xs:element name="description" type="nqupd:LocaleTextType" />
			<xs:element name="text" type="nqupd:LocaleTextType" minOccurs="0" maxOccurs="1" />
			<xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1" />
			<xs:element name="releases" type="nqupd:ReleaseCollectionType" />
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="ReleaseType">
		<xs:sequence>
			<xs:element name="displayversion" type="nqupd:LocaleTextType" />
			<xs:element name="description" type="nqupd:LocaleTextType" />
			<xs:element name="conditions" type="nqupd:ConditionCollectionType" minOccurs="0" maxOccurs="1" />
			<xs:element name="compatibility" type="nqupd:CompatibilityCollectionType" minOccurs="0" maxOccurs="1" />
			<xs:element name="installer" type="nqupd:InstallerFileType" minOccurs ="0" maxOccurs="unbounded" />
		</xs:sequence>
		<xs:attribute name="ver" type="nqupd:VersionIDType" use="required" />
		<xs:attribute name="date" type="xs:date" use="required" />
		<xs:attribute name="experimental" type="xs:boolean" use="optional" />
		<xs:attribute name="recommended" type="xs:boolean" use="optional" />
	</xs:complexType>

	<xs:complexType name="ReleaseRefType">
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="ver" type="nqupd:VersionIDType" use="required" />
	</xs:complexType>

	<xs:complexType name="ReleaseCollectionType">
		<xs:sequence>
			<xs:element name="release" type="nqupd:ReleaseType" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ReleaseRefCollectionType">
		<xs:sequence>
			<xs:element name="release" type="nqupd:ReleaseRefType" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>
</xs:schema>